/*
 heat-spectral lib. solves time-dependent PDEs using SEM-NI method.
 Copyright (C) 2009, Altieri Michele and Stefanoni Andrea
 Copyright (C) 2008, Proverbio Alessandro and Radice David

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

# include "map2d.hpp"

/**
 * \file map2d.cpp
 * \brief This file contains the Map2d  class
 *
 * This file contains the specializations of the operator() for
 * the direct and the inverse map
 */

namespace spectral {

/// Specialization of the operator() for the direct map
template<>
Point<double> Map2d<direct>::operator()(double const & x, double const & y) const {
    double xnew=0.5*(x+1.0)*_lengthX+_Ax;
    double ynew=0.5*(y+1.0)*_lengthY+_Ay;
    return Point<double>(xnew,ynew);
}

/// Specialization of the operator() for the inverse map
template<>
Point<double> Map2d<inverse>::operator()(double const & x, double const & y) const {
    double xnew=(2.0*x-_Ax)/_lengthX-1.0;
    double ynew=(2.0*y-_Ay)/_lengthY-1.0;
    return Point<double>(xnew,ynew);
}

} // namespace
